package com.rc.saas.tenant.mapper.order;

import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.common.base.BaseMapper;
import com.rc.saas.tenant.common.vo.log.OrderTraceVo;
import com.rc.saas.tenant.model.enterprise.EnterpriseSubmember;
import com.rc.saas.tenant.model.invoice.InvoiceOrder;
import com.rc.saas.tenant.model.order.HlhtOrderInfo;
import com.rc.saas.tenant.model.order.OrderInfo;
import com.rc.saas.tenant.model.order.OrderInfoExample;
import com.rc.saas.tenant.search.StatisticsSearch;
import com.rc.saas.tenant.search.acct.OrderAcctBillOrderSearch;
import com.rc.saas.tenant.search.enterprise.EnterpriseOrderSearch;
import com.rc.saas.tenant.search.hlht.HlhtOrderSearch;
import com.rc.saas.tenant.search.order.*;
import com.rc.saas.tenant.search.statistics.ChargeStatisticsSearch;
import com.rc.saas.tenant.vo.elec.ChargeLeaderboard;
import com.rc.saas.tenant.vo.hlht.HlhtOrderPrintVo;
import com.rc.saas.tenant.vo.hlht.HlhtOrderVo;
import com.rc.saas.tenant.vo.order.*;
import com.rc.saas.tenant.vo.order.OrderAllDataVo;
import com.rc.saas.tenant.vo.order.OrderPrintVo;
import com.rc.saas.tenant.vo.order.OrderResult;
import com.rc.saas.tenant.vo.order.OrderTotalData;
import com.rc.saas.tenant.vo.statistics.ChargingStatisticsVo;
import com.rc.saas.tenant.vo.statistics.OperatorPowerTimePeriodVo;
import com.rc.saas.tenant.vo.statistics.OrderChargingStatisticsVo;
import com.rc.saas.tenant.vo.statistics.StatisticsQueryVo;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.cursor.Cursor;
import org.apache.ibatis.mapping.ResultSetType;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface OrderInfoMapper extends BaseMapper<Long, OrderInfo, OrderInfoExample> {
    Long insertReturnId(OrderInfo orderInfo);

    List<OrderResult> listByCondition(OrderSearch orderSearchVo);

   /* //备用旧查询
    List<OrderResult> listByCondition_bak(OrderSearch orderSearchVo);*/

    List<OrderResult> listByHlhtCondition(HlhtOrderInfoSearch hlhtOrderInfoSearch);

    List<HlhtOrderInfoPrintVo> exportHlhtOrderInfo(HlhtOrderInfoSearch hlhtOrderInfoSearch);

    List<OrderResult> listByExceptionOrderCondition(ExceptionOrderInfoSearch exceptionOrderInfoSearch);

    //List<OrderResult> printStation(OrderSearch elecSationSearch);

   /* List<OrderTotalData> listTotalData1(OrderTotalDataSearch orderTotalDataSearchVo);

    List<OrderTotalDataPrintVo> exportTotalData(OrderTotalDataSearch orderTotalDataSearch);

    List<OrderPrintVo> exportOrderInfo(OrderSearch elecSationSearch);*/

    OrderAllDataVo selectTenantOrderByDay(@Param("tenantCode") String tenantCode, @Param("dateType") String dateType);

    OrderAllDataVo selectTenantOrderByDayOperator(@Param("tenantOperatorCode") String tenantOperatorCode, @Param("dateType") String dateType);

    List<ChargeLeaderboard> listStationChargeLeaderboard(String tenantCode);

    OrderAllDataVo selectTenantOrderBylastDate(@Param("tenantCode") String tenantCode, @Param("lastDate") String lastDate);

    OrderAllDataVo selectTenantOrderBylastDateOperator(@Param("tenantOperatorCode") String tenantOperatorCode, @Param("lastDate") String lastDate);

    List<ChargeLeaderboard> listStationChargeLeaderboardOperator(String tenantOperatorCode);

    /**
     * 查询此枪是否生成过订单
     */
    int countOrderByPile(Long elecPileId);

    /**
     * 查询企业会员的所有订单
     */
    List<OrderResult> listEnterpriseOrder(@Param("enterpriseOrderSearch") EnterpriseOrderSearch enterpriseOrderSearch);

    List<OrderPrintVo> exportEnterpriseOrder(@Param("enterpriseOrderSearch") EnterpriseOrderSearch enterpriseOrderSearch);

    List<OrderResult> listOrderByinvoice(@Param("invoiceOrders") List<InvoiceOrder> invoiceOrders);

    List<OrderPrintVo> exportListOrderByinvoice(@Param("invoiceOrders") List<InvoiceOrder> invoiceOrders);

/*    List<HlhtOrderVo> listPageHlhtOrderInfo(HlhtOrderSearch hlhtOrderSearch);

    List<HlhtOrderPrintVo> listHlhtOrderInfo(HlhtOrderSearch hlhtOrderSearch);

    Long listByCondition_COUNT(OrderAcctBillOrderSearch orderSearch);

    List<OrderResult> listOperatorOrderInfo(OrderSearch orderSearch);

    List<OrderPrintVo> exportOperatorOrderInfo(OrderSearch orderSearch);

    OrderInfoCountVo countOrderInfo(OrderInfoStatisticsSearch orderInfoStatisticsSearch);

    List<OrderInfoCountPrintVo> listCountOrderInfo(OrderInfoStatisticsSearch orderInfoStatisticsSearch);*/

    List<ChargingStatisticsVo> listChargingStatistics(StatisticsQueryVo statisticsQueryVO);

    List<OrderChargingStatisticsVo> listOrderChargingStatistics(StatisticsQueryVo statisticsQueryVO);

    OrderResult selectOrderInfo(Long orderId);

    Map<String,Object> getStatementData(@Param("stationName") String stationName,
                                        @Param("provinceId") String provinceId,
                                        @Param("cityId") String cityId,
                                        @Param("areaId") String areaId,
                                        @Param("bizType") String bizType);

    OperatorPowerTimePeriodVo selectOperatorPowerTimePeriod(@Param("elecStationId") Long elecStationId,
                                                            @Param("begin") String begin, @Param("end") String end, @Param("bsBegin") String bsBegin,
                                                            @Param("bsEnd") String bsEnd, @Param("bsBeginHHmm") String bsBeginHHmm);

    /**
     * （迁移专用）
     */
    List<OrderInfo> listhlht1PageOrder(Long memberId);

    /**
     * 流式查询
     */
    //@Options(resultSetType = ResultSetType.FORWARD_ONLY)
    //Cursor<OrderInfo> listOrderInfoByYear(Integer year);

    /**
     * 流式查询
     */
    //@Options(resultSetType = ResultSetType.FORWARD_ONLY)
    //Cursor<OrderInfo> listOrderInfoByDay(Date createdTime);

    OrderInfo selectOrderByOrderNum(String orderNum);

    OrderInfo selectNewOrderByMemberId(@Param("memberId") Long memberId);

    OrderInfo selectByElecGunId(@Param("elecGunId") Long elecGunId);

    OrderInfo selectByOperatorName(@Param("operatorName") String operatorName);

    /**
     *分销商结算数据
     * @param tenantCode
     * @param elecStationId
     * @param startTime
     * @param endTime
     * @param invoiceStartTime
     * @param invoiceEndTime
     * @return
     */
   /* AcctRuleOrderResult AcctRuleOrder(@Param("tenantCode") String tenantCode, @Param("elecStationId") Long elecStationId,
                                      @Param("startTime") String startTime, @Param("endTime") String endTime,
                                      @Param("invoiceStartTime") String invoiceStartTime, @Param("invoiceEndTime") String invoiceEndTime);*/

    /**
     * 导出异常订单修复记录信息
     * @param orderSearch
     * @return
     */
    List<ExceptionOrderPrintVo> exportExceptionOrderInfo(ExceptionOrderInfoSearch orderSearch);

    List<OrderResult> listOperatorExceptionOrderInfo(ExceptionOrderInfoSearch orderSearch);

    HlhtOrderInfo selectHlhtOrderInfoByOrderId(Long orderId);

    List<ExceptionOrderPrintVo> exportOperatorExceptionOrderInfo(ExceptionOrderInfoSearch exceptionOrderInfoSearch);

    List<SaasOrderTotalData> listSaasTotalData1(OrderTotalDataSearch orderTotalDataSearchVo);

    List<SaasOrderTotalDataPrintVo> exportSaasTotalData(OrderTotalDataSearch orderTotalDataSearchVo);

    SaasOrderInfoCountVo saasCountOrderInfo(OrderTotalDataSearch orderTotalDataSearch);

    List<SaasOrderInfoCountPrintVo> listSaasCountOrderInfo(OrderTotalDataSearch orderTotalDataSearch);

    List<OrderInfoMonitorVo> selectByGunIdList(@Param("gunList")List<Long> gunList);

    OrderAllDataVo countAllOrder(StatisticsSearch search);

    List<OrderResult> listOrderInIds(@Param("ids") List<Long> ids);

    List<ChargeLeaderboard> countStationOrderRank(StatisticsSearch search);

    List<ChargeStatisticsResult> listChargeStatistics(ChargeStatisticsSearch search);

    List<OrderTraceVo> listOrderTrace(OrderTraceVo orderTraceVo);

}
